/*
 * Copyright 2006-2022 ahtelit.com, All Rights Reserved.
 */

package com.telit.dispose.feign;

import com.telit.common.constant.Constant;
import com.telit.common.entity.DataReturn;
import com.telit.common.entity.PageData;
import com.telit.dispose.dto.PlatMetaTableEntityDTO;
import com.telit.dispose.entity.dispose.PlatMetaFieldEntity;
import com.telit.dispose.entity.resourceManagement.Dict;
import com.telit.dispose.feign.factory.RemoteDisposeServiceFallbackFactory;
import com.telit.dispose.model.QryDeviceListRequest;
import com.telit.dispose.model.QryDeviceModel;
import com.telit.dispose.model.QryResourceListRequest;
import com.telit.dispose.model.QryResourceModel;
import com.telit.dispose.vo.resourceManagement.DictVO;
import com.telit.dispose.vo.resourceManagement.ResourceCategoryVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * dispose feign
 *
 * @author yuezhuang
 * @since 2022-12-14
 */
@FeignClient(contextId = "remoteDisposeService", name = "yichang-dispose", fallbackFactory = RemoteDisposeServiceFallbackFactory.class)
public interface RemoteDisposeService {

    @GetMapping(value = "/dispose/api/table/selectAllTable")
    DataReturn selectAllTable(@RequestParam(value = "flag") String flag);

    @GetMapping(value = "/dispose/api/table/selectTableInfoByTableName")
    DataReturn selectTableInfoByTableName(@RequestParam(value = "tables") String tables,
                                          @RequestParam(value = "districtCode") String districtCode);


    @GetMapping(value = "/dispose/dict/findDictInfoByCode")
    DataReturn findDictInfoByCode(@RequestParam(value = "parentCode") String parentCode,
                                  @RequestParam(value = "childCode") String childCode);

    @GetMapping(value = "/dispose/dict/findDict")
    DataReturn<List<DictVO>> findDictByDictType(@RequestParam(value = "code") String code);

    @GetMapping(value = "/dispose/fire-resource/topFloorDownChildrenList")
     DataReturn<List<ResourceCategoryVO>> topFloorDownChildrenList(
            @RequestParam(value = "parentId", required = false) Long parentId,
            @RequestParam(value = "longitude", required = false) String longitude,
            @RequestParam(value = "latitude", required = false) String latitude,
            @RequestParam(value = "radius", required = false) String radius,
            @RequestParam(value = "districtCode", required = false) String districtCode
    );


    @PostMapping(value = "/dispose/dict/findDictInsert")
    DataReturn dictInsert(@RequestBody Dict dict);


    @GetMapping(value = "/dispose/dict/deleteDictById")
    DataReturn deleteDictById(@RequestParam(value = "id") Long id);


    @GetMapping(value = "/dispose/dict/selectByDictId")
    DataReturn<Dict> selectByDictId(@RequestParam(value = "id") Long id);

    @ApiOperation(httpMethod = Constant.REQUEST_METHOD_GET, value = "查询资源列表（返回指定公共字段）")
    @GetMapping(path = "/dispose/fire-resource/qry-resource-list")
    DataReturn<PageData<List<QryResourceModel>>> qryResourceList(
            @SpringQueryMap QryResourceListRequest qryResourceListRequest);

    @ApiOperation(httpMethod = Constant.REQUEST_METHOD_GET, value = "查询设备列表（返回指定公共字段）")
    @GetMapping(path = "/dispose/fire-resource/qry-device-list")
    DataReturn<PageData<List<QryDeviceModel>>> qryDeviceList(@SpringQueryMap QryDeviceListRequest qryDeviceListRequest);

    @ApiOperation(httpMethod = Constant.REQUEST_METHOD_GET, value = "设施详情")
    @GetMapping(path = "/dispose/fire-resource/qry-device-detail/{tableId}/{id}")
    DataReturn<QryDeviceModel> qryDeviceDetail(@PathVariable(value = "tableId") String tableId,
                                               @PathVariable(value = "id") String id);

    @ApiOperation(httpMethod = Constant.REQUEST_METHOD_GET, value = "资源详情")
    @GetMapping(path = "/dispose/fire-resource/qry-resource-detail/{tableId}/{id}")
    DataReturn<QryResourceModel> qryResourceDetail(@PathVariable(value = "tableId") String tableId,
                                                   @PathVariable(value = "id") String id);

    @GetMapping("/dispose/api/table/selectTableAndFilesByTableId")
    @ApiOperation("查询物理表已经对应的表字段")
    DataReturn<List<PlatMetaFieldEntity>> selectTableAndFilesByTableId(@RequestParam("tableId") String tableId);

    @GetMapping("/dispose/api/data")
    @ApiOperation("根据service查询不同的接口")
    DataReturn dateSelectByService(@RequestParam(value = "tableId", required = false) String tableId,
                                   @RequestParam(value = "service", required = true) String service,
                                   @RequestParam(value = "current", required = false) Integer current,
                                   @RequestParam(value = "size", required = false) Integer size,
                                   @RequestParam(value = "name", required = false) String name,
                                   @RequestParam(value = "data", required = false) String data,
                                   @RequestParam(value = "detailId", required = false) String detailId,
                                   @RequestParam(value = "xzqhcode", required = false) String xzqhcode);

    @GetMapping("/dispose/api/table/selectTableByTableId")
    @ApiOperation("根据tableId查询对应表数据")
    DataReturn<PlatMetaTableEntityDTO> selectTableByTableId(@RequestParam("tableId") String tableId);

}
